package com.svse.designPattern.behaviour.memento;

/**
 * @author LiYuhang
 * @version 0.1
 * @application
 * @Date 2020/8/9 10:11
 */
public class OriginatorPrototype implements Cloneable {
    private String state;

    public String getState() {
        return state;
    }

    public void setState(String state) {
        this.state = state;
    }

    public OriginatorPrototype createMemento()  {
        return  this.clone();
    }
    public void restoreMemento(OriginatorPrototype originatorPrototype){
        this.setState(originatorPrototype.getState());
    }
    public OriginatorPrototype clone(){
        try {
            return (OriginatorPrototype) super.clone();
        } catch (CloneNotSupportedException e) {
            e.printStackTrace();
        }
        return  null;
    }
}
